package com.cy.pj.common.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
@NoArgsConstructor
public class JsonResult implements Serializable {
    private static final long serialVersionUID = 2080943344863436345L;
    private int state = 1;          //状态码
    private String message = "OK";  //状态信息
    private Object data;            //查询数据

    //一般查询时调用,封装查询结果
    public JsonResult(String message) {
        this.message = message;
    }
    public JsonResult(Object data) {
        this.data = data;
    }

    //出现异常时调用
    public JsonResult(Throwable t){
        this.state = 0;
        this.message = t.getMessage();
    }
}
